package com.whnk.report.service.impl;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.whnk.report.constant.RptConstants;
import com.whnk.report.domain.CompEmp;
import com.whnk.report.domain.EChartsData;
import com.whnk.report.domain.SeriesData;
import com.whnk.report.mapper.CompEmpMapper;
import com.whnk.report.service.ICompEmpService;

/**
 * 报表统计 服务层实现
 * 
 * @author whwhnk
 * @date 2019-02-27
 */
@Service
public class CompEmpServiceImpl implements ICompEmpService 
{
	@Autowired
	private CompEmpMapper compEmpMapper;
	
	/**
     * 查询供应商统计人数报表
     * 
     * @param compEmp
     * @return 统计集合
     */
	@Override
	public EChartsData selectCompEmpRpt()
	{
		EChartsData eChartData = new EChartsData();
		List<CompEmp> list = compEmpMapper.selectCompEmpRpt();
		
        List<SeriesData> series = new ArrayList<SeriesData>();
        List<String> legendData = new ArrayList<String>();
		
        SeriesData seriesData = new SeriesData();
        
        for(CompEmp item : list) {
        	String comp = item.getEmpComp();
        	legendData.add(comp);
        	seriesData = new SeriesData();
        	seriesData.setName(comp);
        	seriesData.setValue(String.valueOf(item.getEmpCount()));
    		series.add(seriesData);
        }
        
        eChartData.setTitle(RptConstants.COMP_EMP_TITLE);
        eChartData.setLegendData(legendData);
        eChartData.setSeriesData(series);
        
	    return eChartData;
	}
	
}
